package com.m1905hd.utils;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.web.servlet.View;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author weiwei.huang
 * @email ihuangweiwei@163.com
 * @date 15/6/16
 */
public class ExeclView implements View {
    @Override
    public String getContentType() {
        return null;
    }

    @Override
    public void render(Map<String, ?> stringMap, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        httpServletResponse.setHeader("content-disposition", "attachment;filename=" + System.currentTimeMillis() + ".xls");
        HSSFWorkbook workbook = (HSSFWorkbook) stringMap.get("workbook");
        workbook.write(httpServletResponse.getOutputStream());

    }
}
